package com.itheima.app.controller;

import com.itheima.app.manager.SettingManager;
import com.itheima.domain.db.Notification;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class SettingController {

    @Autowired
    private SettingManager settingManager;

    @GetMapping("/users/settings")
    public ResponseEntity findSettingVo() {

        ResponseEntity settingVo = settingManager.findSettingVo();

        return settingVo;
    }

    @PostMapping("/users/questions")
    public void setQuestion(@RequestBody Map<String, String> map) {

        String content = map.get("content");

        settingManager.setQuestion(content);
    }

    @PostMapping("/users/notifications/setting")
    public void setNotification(@RequestBody Notification param) {
        // 调用manager
        settingManager.setNotification(param);
    }

    @GetMapping("/users/blacklist")
    public ResponseEntity findBlackListByPage(@RequestParam(value = "page", defaultValue = "1") Integer pageNum,
                                              @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {

        return settingManager.findBlackListByPage(pageNum, pageSize);
    }

    @DeleteMapping("/users/blacklist/{blackUserId}")
    public void deleteBlackList(@PathVariable Long blackUserId) {

        settingManager.deleteBlackList(blackUserId);
    }
}
